/**
 * Created by zhourh on 2018/5/22.
 */
public class JudgeRouteCircle {

    public static void main(String[] args) {
        System.out.println(new JudgeRouteCircle().judgeCircle("UD"));
        System.out.println(new JudgeRouteCircle().judgeCircle("LL"));
    }

    public boolean judgeCircle(String moves) {
        int horizontalDistance = 0;
        int verticalDistance = 0;
        if (moves == null || moves.isEmpty()) {
            return true;
        }
        char[] directions = moves.toCharArray();

        for (char direction : directions) {
            switch (direction) {
                case 'U':
                    verticalDistance++;
                    break;
                case 'D':
                    verticalDistance--;
                    break;
                case 'R':
                    horizontalDistance++;
                    break;
                case 'L':
                    horizontalDistance--;
                    break;
                default:
                    break;
            }
        }

        return horizontalDistance == 0 && verticalDistance == 0;
    }
}
